<template>
  <div>
    <el-card class="card">
      <el-row>
        <el-col :span="8">
          <el-input
            placeholder="请输入内容"
            class="input-with-select"
          >
            <el-button slot="append" icon="el-icon-search"></el-button>
          </el-input>
        </el-col>
        <el-col :span="4">
            <!-- 点击按钮跳转到弹框 -->
          <el-button type="primary" @click="$router.push('/addgoods')">添加商品</el-button>
        </el-col>
      </el-row>
      <!-- 表格 -->
      <el-table :data=" goodsList" stripe style="width: 100%">
        <el-table-column type="index" label="#" width="180">
        </el-table-column>
        <el-table-column prop="goods_name" label="商品名称" width="180">
        </el-table-column>
        <el-table-column prop="goods_price" label="商品价格"> </el-table-column>
        <el-table-column prop="goods_weight" label="商品重量"> </el-table-column>
        <el-table-column prop="add_time" label="创建时间"> </el-table-column>
        <el-table-column label="操作"> 
            <!-- 编辑 -->
            <el-button
              type="primary"
              icon="el-icon-edit"
              size="small"
            ></el-button>
            <!-- 删除 -->
            <el-button
              type="danger"
              size="small"
              icon="el-icon-delete"
          ></el-button>
       
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
import {getGoodList} from 'api/goods'
export default {
  name: "goods",
  data() {
    return {
         goodsList:[],
         queryInfo:{
            query:'',//搜索关键字
            pagenum:1,
            pagesize:10,
         }
    }
  },
  created(){
     this.getGoodList()
  },
  methods:{
    async getGoodList(){
        const res=await getGoodList(this.queryInfo)
   
        this.goodsList=res.goods
        this.total=res.total
    }
  }
};
</script>

<style lang="scss" scoped>
</style>